/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AccessFileLoader.java
 *
 * Created on 04.04.2012, 15:02:02
 */
package com.google.code.fishing.gui;

/**
 *
 * @author n4
 */
public class FileLoader extends javax.swing.JFrame {

    private MainFrame mDF;
    
    /** Creates new form AccessFileLoader */
    public FileLoader(MainFrame f) {
        mDF = f;
        
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mChooser = new javax.swing.JFileChooser();

        mChooser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mChooserActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mChooserActionPerformed
        
        if(evt.getActionCommand().equals("ApproveSelection")) {
            mDF.setFile(mChooser.getSelectedFile().getAbsolutePath());
            this.setVisible(false);
        }
        
        if(evt.getActionCommand().equals("CancelSelection")) {
            this.setVisible(false);
        }
        
    }//GEN-LAST:event_mChooserActionPerformed

    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFileChooser mChooser;
    // End of variables declaration//GEN-END:variables
}
